home *** CD-ROM | disk | FTP | other *** search
- #include <dos.h>
- #include <stdio.h>
-
- /* This is a simple terminal program using the software nullmodem
- hook in MSYS. The nullmodem.exe tsr must be loaded before your
- multisession operating system (like windows or desqview). Then
- start MSYS in one window and this program in another. */
-
-
- int intnum=0;
-
- void send(int c)
- {
- union REGS regs;
- while (1)
- {
- regs.x.ax=0;
- int86(intnum,®s,®s);
- if (regs.x.ax&1) break;
- }
-
- regs.x.ax= (c<<8) | 2;
- int86(intnum,®s,®s);
- }
-
- int receive()
- {
- union REGS regs;
- while (1)
- {
- regs.x.ax=0;
- int86(intnum,®s,®s);
- if (regs.x.ax&2) break;
- }
- regs.x.ax=1;
- int86(intnum,®s,®s);
- return regs.x.ax & 255;
- }
-
- int ready()
- {
- union REGS regs;
- regs.x.ax=0;
- int86(intnum,®s,®s);
- return regs.x.ax & 2;
- }
-
- void cdon()
- {
- union REGS regs;
- regs.x.ax=3;
- int86(intnum,®s,®s);
- }
-
- void cdoff()
- {
- union REGS regs;
- regs.x.ax=4;
- int86(intnum,®s,®s);
- }
-
-
- void main(int argc, char *argv[])
- {
- int c;
- if (argc!=2) {printf("Usage: %s hex-int\n",argv[0]);exit(1);}
- sscanf(argv[1],"%x",&intnum);
- printf("Using interrupt %X\n",intnum);
- cdon();
-
-
- while (1)
- {
- if (kbhit())
- {
- c=getch();
- if (c==27) break;
- send(c);
- }
- if (ready()) putchar(receive());
- }
- cdoff();
- }
-
-